﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Hyt.Core
{
    public abstract class Repository<TEntity> where TEntity : class
    {
        public IPersistService PersistService { get; set; }

        public IQueryable<TEntity> GetQuery(QueryOption<TEntity> option = null)
        {
            return PersistService.GetQuery<TEntity>(option);
        }

        public TEntity Get(params object[] keys)
        {
            return PersistService.Get<TEntity>(keys);
        }

        public void Add(TEntity model)
        {
            PersistService.Add(model);
        }

        public void Update(TEntity model)
        {
            PersistService.Update(model);
        }

        public void AddOrUpdate(params TEntity[] models)
        {
            PersistService.AddOrUpdate(models);
        }

        public void Remove(TEntity model)
        {
            PersistService.Remove(model);
        }
    }
}
